|
|
|
|
|
|
|
In endpoint interpolation, you use linear interpolation to compute the endpoints of the line segment in the tweens. Suppose you want to create seven tweens between two key frames. Starting from the first key frame, you move the segment's endpoints one-eighth of the distance closer to their final positions during each tween. This produces seven sets of endpoints evenly spaced between the key frames. Another one-eighth of the distance gives the final segment's position. |
|
|
|
|
|
|
|
|
The following code fragment shows how you could compute the endpoint positions. The values (x11, y11) and (x12, y12) are the endpoint coordinates in the first key frame, and (x21, y21) and (x22, y22) are the coordinates in the second. |
|
|
|
 |
|
|
|
|
Dim i As Integer
Dim x1 As Single
Dim y1 As Single
Dim x2 As Single
Dim y2 As Single
Dim dx1 As Single
Dim dy1 As Single
Dim dx2 As Single
Dim dy2 As Single
' Compute the differences between the tweens. dx1 = (x21 - x11) / (num_tweens + 1)
dyl = (y21 - y11) / (num_tweens + 1)
dx2 = (x22 - x12) / (num_tweens + 1)
dy2 = (y22 - y12) / (num_tweens + 1)
' Compute the tweens' end points. x1 = x11
y1 = y11
x2 = x12
y2 = y12
For i = 1 To num_tweens ' Compute the new endpoint coordinates. x1 = x1 + dx1
y1 = y1 + dy1
x2 = x2 + dx2
y2 = y2 + dy2
' Save the tween end points (x1, y1) and (x2, y2).
: Next i |
|
|
|
|
|
|
|
|
Figure 9.4 shows the resulting frames for the segments in Figure 9.3. The segments are drawn on the same picture so you can see how they change from frame to frame. |
|
|
|
|
|
|
|
|
Example program TweenEnd creates tweens using endpoint interpolation. Select Load from the File menu to load a data file describing an animation. This file should begin |
|
|
|
|
|